package com.zc.timer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDateTime;

/**
 * 新建一个定时任务
 */

@Configuration  //标记配置类，使得spring容器可以扫描到
@EnableScheduling  //开启定时任务
@Slf4j
public class TaskTest {

    /**
     * 添加一个定时任务，并且注明任务的运行表达式
     */
    @Scheduled(cron = "*/2 * * * * ?")
    public void publishMsg() {
        //log.warn("开始执行定时任务：" + LocalDateTime.now());
    }
}
